import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-12-06
 * Time: 20:14
 */

//倒置字符串
//https://www.nowcoder.com/practice/ee5de2e7c45a46a090c1ced2fdc62355?tpId=85&&tqId=29867&rp=1&ru=/activity/oj&qru=/ta/2017test/question-ranking
public class Inversion {
    //I like beijing.  输入前
    //beijing. like I  导致后


    //解体思路 先将整个字符串导致 然后 在倒置单个单词
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //nextLine 遇到空格不停下来
        String str1 = scan.nextLine();
        //System.out.println(str1.length()); //15
        //将字符串 改为字符数组 方便逆置
        char[] ch = str1.toCharArray();
        nizhi(ch,0,str1.length()-1); //0-14有效字符

        int i = 0;
        while (i <str1.length()){
            int j = i;
            //如果逆置的是 只有一个单词 那么 不能一直++
            while (j < str1.length() && ch[j] != ' '){
                j++;
            }

            if (j < str1.length()){
                nizhi(ch,i,j-1);
                i = j+1;
            }else {
                //当j走到最后一个单词的 最后一个字母的时候
                nizhi(ch,i,j-1);
                i = j;
            }
        }
        String str2 = new String(ch);
        System.out.println(str2);
    }

    private static void nizhi(char[] chars, int start, int end) {
        //将整个字符数组逆置  前后指针
        while (start < end){
            char tmp = chars[start];
            chars[start] = chars[end];
            chars[end] = tmp;
            start++;
            end--;
        }
    }

}
